<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>编辑课程</title>


<link href="${base}/resources/admin/css/amazeui.css" rel="stylesheet" type="text/css" />
<link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        .text-line {
            line-height: 20px;
        }
        #courseImage {
            cursor: pointer;
        }
    </style>

</head>
<body>
	<div class="path">
		<a href="${base}/asl-admin/common/index.htm">${message("admin.path.index")}</a> &raquo; 编辑课程
	</div>
	<form id="inputForm" action="update.htm" method="post">
		<input type="hidden" name="id" value="${course.id}" />
		<table class="input">
            <tr>
                <th>
                    <span class="requiredField"></span>老师:
                </th>
                <td>
                    <span>[#if course.member??]${course.member.username}[/#if]</span>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField"></span>分类:
                </th>
                <td>
                    <span class="am-badge am-badge-primary am-radius">[#if course.category??]${course.category.name}[/#if]</span>
                </td>
            </tr>
            <tr>
                <th>
                    封面:
                </th>
                <td>
                <span class="fieldSet">
                    <input type="text" name="imageURL" class="text" value="${course.imageURL}" maxlength="200" title="${message("admin.imageTitle")}" />
                    <input type="button" id="browserButton" class="button" value="${message("admin.browser.select")}" />
				[#if course.imageURL??]
                    <img src="${course.imageURL}" class="browserImage" id="courseImage"/>
				[/#if]
                </span>
                </td>
            </tr>
			<tr>
				<th>
					<span class="requiredField">*</span>标题:
				</th>
				<td>
					<input type="text" name="title" class="text" value="${course.title}" maxlength="200" />
				</td>
			</tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>开播日期:
                </th>
                <td>
                    <input type="text" id="birth" name="pattern" class="text Wdate" onfocus="WdatePicker({minDate:'%y-%M-%d', dateFmt: 'yyyy-MM-dd HH:mm'});" value="[#if course.datePattern]${course.datePattern?string("yyyy-MM-dd HH:mm")}[/#if]" placeholder="请选择日期"/>
                </td>
            </tr>
            <tr>
                <th>
                    简介:
                </th>
                <td>
                    <textarea name="introduction" class="text text-line"  style="width: 400px;height: 200px">${course.introduction}</textarea>
                </td>
            </tr>
            <tr>
                <th>
                    是否置顶:
                </th>
                <td>
                    <label><input type="radio" name="isTop" value="true"  [#if course.isTop==true] checked[/#if] />是</label>
                    <label><input type="radio" name="isTop" value="false" [#if course.isTop==false] checked[/#if] />否</label>
                </td>
            </tr>
            [#if course.courseType!="nolive"]
            <tr>
                <th>
                    是否处于热门搜索:
                </th>
                <td>
                    <label><input type="radio" name="hotSearch" value="true"  [#if course.hotSearch==true] checked[/#if] />是</label>
                    <label><input type="radio" name="hotSearch" value="false" [#if course.hotSearch==false] checked[/#if] />否</label>
                </td>
            </tr>
            [/#if]
            <tr>
                <th>
				    是否收费:
                </th>
                <td>
                    <label>
                        <input type="checkbox" id="charge" name="charge" value="true"[#if course.charge] checked="checked"[/#if] />是
                    </label>
                </td>
            </tr>
            <tr id="charge-encrypt">
                <th>
				    是否加密:
                </th>
                <td>
                    <label>
                        <input type="checkbox" id="encrypt" name="encrypt" value="true"[#if course.encrypt] checked="checked"[/#if] />是
                    </label>
                </td>
            </tr>

            <tr id="password">
                 [#if course.encrypt == "true"]
                <th>
                    <span class="requiredField">*</span>密码:
                </th>
                <td>
                    <input type="text" id="password" name="password" value="${course.password}" class="text" placeholder="请输入数字密码，最少为6位"/>
                </td>
                [/#if]
            </tr>

            <tr id="price">
            [#if course.charge == "true"]
                <th>
                    <span class="requiredField">*</span>价格:
                </th>
                <td>
                    <input type="text" name="price" class="text" value="${course.price}" placeholder="请输入价格,保留两位小数"/>
                </td>
            [/#if]
            </tr>
            <tr>
                <th>
                    <span class="requiredField"></span>视频详情:
                </th>
                <td>
                    [#if course.live??]
                        <a href="/asl-admin/live/edit.htm?id=${course.live.id}">视频详情</a>
                    [/#if]
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField"></span>创建时间:
                </th>
                <td>
                    <span>${course.createDate}</span>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField"></span>状态:
                </th>
                <td>
                [#if course.type=="trailer"]
                    <span class="am-badge am-badge-secondary am-radius">${course.type.toValue()}</span>
                [#else]
                    <span class="am-badge am-badge-warning am-radius">${course.type.toValue()}</span>
                [/#if]
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField"></span>直播状态:
                </th>
                <td>
                [#if course.courseType=="nolive"]
                    <span class="am-badge am-badge-secondary am-radius">${course.courseType.toValue()}</span>
                [#elseif course.courseType=="live"]
                    <span class="am-badge am-badge-success am-radius">${course.courseType.toValue()}</span>
                [#else]
                    <span class="am-badge am-badge-warning am-radius">${course.courseType.toValue()}</span>
                [/#if]
                </td>
            </tr>
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="submit" class="button" value="${message("admin.common.submit")}" />
					<input type="button" class="button" value="${message("admin.common.back")}" onclick="location.href='list.htm'" />
				</td>
			</tr>
		</table>
	</form>
</body>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.tools.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/admin/editor/kindeditor.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
<script type="text/javascript" src="${base}/resources/admin/datePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $().ready(function() {

        var $inputForm = $("#inputForm");
        var $browserButton = $("#browserButton");
        var $charge = $("#charge");
        var $price = $("#price");
        var $encrypt = $("#encrypt");
        var $password = $("#password");
        var $charge_encrypt = $("#charge-encrypt");

        $charge.on("click", function () {
            if($(this).attr("checked") == null){
                $price.hide();
                $price.empty();
                $charge_encrypt.hide();
                $password.hide();
            } else {
                $price.show();
                $charge_encrypt.show();
                var shtml = '<th><span class="requiredField">*</span>价格:</th><td><input type="text" name="price" class="text" placeholder="请输入价格,保留两位小数"/></td>';
                $price.html(shtml);
                if ($encrypt.attr("checked") != null) {
                    $password.empty();
                    $password.show();
                    var shtml = '<th><span class="requiredField">*</span>密码:</th><td><input type="text" name="password" class="text" placeholder="请输入数字密码，最少为6位"/></td>';
                    $password.html(shtml);
                }
            }
        })

        $encrypt.on("click", function () {
            if($(this).attr("checked") == null){
                $password.hide();
                $password.empty();
            } else {
                $password.show();
                var shtml = '<th><span class="requiredField">*</span>密码:</th><td><input type="text" name="password" class="text" placeholder="请输入数字密码，最少为6位"/></td>';
                $password.html(shtml);
            }
        })

        $("#courseImage").on("click", function() {
            window.open($(this).attr("src"));
        })

    [@flash_message /]

        $browserButton.browser();

        // 表单验证
        $inputForm.validate({
            rules: {
                title: "required",
                pattern: "required",
                introduction : "required",
                password: {
                    pattern:/^[0-9]*$/,
                    minlength: 6,
                    maxlength: 20,
                    required:true
                },
                price: {
                    min: 0.01,
                    pattern:/^(([0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/,
                    required:true
                }
            },
        });

    });
</script>
</html>
